# 762 简单：二进制表示中质数个计算置位

def countPrimeSetBits(left: int, right: int) -> int:
    def getNum(num):
        n = 0
        while num:
            if num % 2:
                n += 1
            num = num // 2
        # print(n)
        return n

    def isNum(num):
        if num == 1:
            return False
        elif num < 3:
            return True
        for j in range(2, int(num ** .5)):
            if num % j:
                return False
        return True

    ret = 0

    for i in range(left, right + 1):
        if isNum(getNum(i)):
        # if isNum(i.bit_count()):
            ret += 1

    return ret


print(countPrimeSetBits(6, 10))
